//前提
var mongoose = require("mongoose")

//引用插件
var mongoosePaginate = require('mongoose-paginate');

//约束
var schema = new mongoose.Schema({
  person_name: {
    type: mongoose.Schema.Types.ObjectId,
  },
  modules_type: {
    type: mongoose.Schema.Types.ObjectId,
  },
  type: {
    type: mongoose.Schema.Types.ObjectId,
  },
  content: {
    type: String,
    required: [true, "评论内容不能为空"],
    maxlength: 200,
    minlength: [20, '评论内容不得少于20字']
  },
  good: { //点赞数量
    type: Number
  },
  status: Boolean, //是否为优质评论
  pro_data: {  //发表时间
    type: Date,
    default: Date.now
  },
  source: {  //地址
    type: String,
    required: [true, "地址不能为空"],
      },
});



//引入插件
schema.plugin(mongoosePaginate);

//实例化
module.exports = mongoose.model('Comment', schema, 'comment'); // Model.paginate()